package com.itdonghudng.bigtest1;

import java.util.Scanner;

public class Bodytest {
    public static void main(String[] args) {

        System.out.println("请输入用户信息：");

        Scanner in = new Scanner(System.in);

        System.out.println("请输入年龄：");

        int age = in.nextInt();

        System.out.println("请输入性别：");

        String sex = in.next();

        System.out.println("请输入身高：");

        double height = in.nextDouble();

        System.out.println("请输入体重：");

        double weight = in.nextDouble();

        double bmi = bmi(height,weight);

        System.out.println("bmi="+bmi);

        if (bmi < 18.5) {
            System.out.println("过轻");
        } else if (bmi >= 18.5 && bmi < 24) {
            System.out.println("正常");
        } else if (bmi >= 24 && bmi < 28) {
            System.out.println("过重");
        } else {
            System.out.println("肥胖");
        }

        double bmr = bmr(age,sex,height,weight);

        System.out.println("bmr="+bmr);

    }
    //计算一个人的BMI指数
    public static double bmi(double height,double weight){

        return weight/(height*height);

    }
    //计算一个人的BMR指数
    public static double bmr(int age,String sex,double height,double weight){
        double bmr = 0;
        if (sex.equals("男")){
            bmr = 66 + (13.7 * weight) + (5 * height) - (6.8 * age);
        }else{
            bmr = 655 + (9.6 * weight) + (1.8 * height) - (4.7 * age);
        }
        return bmr;
    }
}